/*
 * @Author: zhang ke
 * @Date: 2025-07-02 10:25:51
 * @LastEditors: your name
 * @LastEditTime: 2025-07-05 16:32:51
 * @Description: 
 * @FilePath: \vue3-admin\src\api\acl\user\index.ts
 */
import type { UserResponseData } from "@/api/user/type";
import request from "@/utils/request";
//接口地址
enum API {
    ALLUSER_URL = '/acl/user/',
    ADDUSER_URL = '/acl/user/save',
    UPDATEUSER_URL = '/acl/user/update',
    DELECTUSER_URL = '/acl/user/remove/',
    ALLROLE_URL = '/acl/user/toAssign/',
    SETROLE_URL = '/acl/user/doAssignRole/',
    DELETEALLUSER_URL = '/acl/user/batchRemove',

}
//获取列表
export const reqUserInfo = (page:number,limit:number,username:string)=>{
    return request.get<any,UserResponseData>(API.ALLUSER_URL+`${page}/${limit}/?username=${username}`)
}
//新增和编辑的接口
export const reqAddOrUpdateUser = (data:any)=>{
    if(data.id){
        return request.put<any,any>(API.UPDATEUSER_URL,data)
    }else{
        return request.post<any,any>(API.ADDUSER_URL,data)
    }
}

//删除的接口
export const reqDelectUser = (id:number| string)=>{
    return request.delete<any,any>(API.DELECTUSER_URL + id)
}

//用户角色
export const reqAllRole = (userId:number)=>{
    return request.get<any,any>(API.ALLROLE_URL + userId)
}
//分配用户角色
export const reqSettUserRole = (data:any)=>{
    return request.post<any,any>(API.SETROLE_URL,data)
}
//批量删除
export const reqSelectUser = (idList: number[]) =>
  request.post(API.DELETEALLUSER_URL, { data: idList })